home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Games / Showwit! 1.0 / source code / Source / CShTile.p < prev    next >
Encoding:
Text File  |  1996-02-03  |  28.8 KB  |  1,276 lines  |  [TEXT/PJMM]

  1. {****************************************************}
  2. {}
  3. {        CShTile.p                                                                                                                                                                                                                }
  4. {}
  5. {        Pane class for the Showwit tiles. When clicked, these tiles flip between hiding    }
  6. {     and showing a target picture. The target is a PixMap pane, and the pane is a            }
  7. {        "window" into the part of the picture concealed by the tile. The hiding side is        }
  8. {        a color icon, at the    centre of the pane. We override the DrawAll method to            }
  9. {        draw only one of these panes. We use a color icon so that the hiding side of the    }
  10. {        tile automatically adapts to the correct screen depth.    If Color QuickDraw is        }
  11. {        not present, then the color icon pane uses the black and white icons anyway.        }
  12. {}
  13. {****************************************************}
  14.  
  15.  
  16. unit CShTile;
  17.  
  18. interface
  19.  
  20.     uses
  21.         ShIntf;
  22.  
  23. implementation
  24.  
  25. {****************************************************}
  26. {}
  27. {        IShTile                                                                                                                                                                                                                        }
  28. {}
  29. {        Construction of the Showwit Tile object.                                                                                                                     }
  30. {}
  31. {****************************************************}
  32.  
  33.     procedure CShTile.IShTile (anEnclosure: CView;
  34.                                     aSupervisor: CShGameDirector;
  35.                                     aHEncl, aVEncl: integer;
  36.                                     aHSizing, aVSizing: SizingOption);
  37.  
  38.         var
  39.             thePixMapPane: CPixMapPane;
  40.             theTileLRect: LongRect;
  41.  
  42.             theIcon: CIconPane;
  43.  
  44.     begin { IShTile }
  45.         itsPixMapPane := nil;
  46.         itsIcon := nil;
  47.  
  48.         itsGameDirector := aSupervisor;
  49.  
  50.         IPane(anEnclosure, aSupervisor, kTileSize, kTileSize, aHEncl, aVEncl, aHSizing, aVSizing);
  51.         SetWantsClicks(TRUE);
  52.  
  53.         { CShTile needs random numbers. This is a good place to initialize the random seed. }
  54.         RandSeed := TickCount;
  55.  
  56.         { Create PixMap pane with offscreen bitmap and port. }
  57.         SetLongRect(theTileLRect, 0, 0, kTileSize, kTileSize);
  58.         new(thePixMapPane);
  59.         thePixMapPane.IPixMapPane(SELF, SELF, kTileSize, kTileSize, 0, 0, aHSizing, aVSizing, theTileLRect, nil, TRUE);
  60.         itsPixMapPane := thePixMapPane;
  61.  
  62.         new(theIcon);
  63.         theIcon.IIconPane(SELF, SELF, (kTileSize - kIconPixels) div 2, (kTileSize - kIconPixels) div 2, aHSizing, aVSizing, cicnTile, TRUE);
  64.         itsIcon := theIcon;
  65.  
  66.         { Both itsPixMapPane and itsIcon are visible. We ensure that only one is drawn. }
  67.  
  68.     end; { IShTile }
  69.  
  70.  
  71. {****************************************************}
  72. {}
  73. {        Free                                                                                                                                                                                                                                }
  74. {}
  75. {     Destruction of the Showwit Tile object. We set our pointers to nil, for the                 }
  76. {        objects to which they were pointing will be disposed of in inherited methods.         }
  77. {}
  78. {****************************************************}
  79.  
  80.     procedure CShTile.Free;
  81.  
  82.     begin { Free }
  83.         { The PixMap pane and icon are in the drawing heirarchy, }
  84.         {    and will be disposed of in the inherited methods. }
  85.         itsPixMapPane := nil;
  86.         itsIcon := nil;
  87.  
  88.         { The game director is the tile's supervisor. It will be }
  89.         { disposed of in the inherited methods. Set our pointer }
  90.         { to nil here. }
  91.         itsGameDirector := nil;
  92.  
  93.         inherited Free;
  94.     end; { Free }
  95.  
  96.  
  97. {****************************************************}
  98. {}
  99. {        GetState                                                                                                                                                                                                                    }
  100. {}
  101. {     Returns the current state of the tile, whether showing or hiding.                                             }
  102. {}
  103. {****************************************************}
  104.  
  105.     function CShTile.GetState: TileState;
  106.  
  107.     begin { GetState }
  108.         GetState := itsState;
  109.     end; { GetState }
  110.  
  111.  
  112. {****************************************************}
  113. {}
  114. {        GetState                                                                                                                                                                                                                    }
  115. {}
  116. {         Sets the state of the tile to showing or hiding as appropriate.                                                     }
  117. {}
  118. {****************************************************}
  119.  
  120.     procedure CShTile.SetState (aState: TileState);
  121.  
  122.     begin { SetState }
  123.         itsState := aState;
  124.  
  125.         { If this method is ever changed, then change DoFlip also. }
  126.     end; { SetState }
  127.  
  128.  
  129. {****************************************************}
  130. {}
  131. {        SetGridPos                                                                                                                                                                                                            }
  132. {}
  133. {        The position of the tile in the grid has been set.                                                                                                }
  134. {}
  135. {****************************************************}
  136.  
  137.     procedure CShTile.SetGridPos (aGridPos: TileRange);
  138.  
  139.     begin
  140.         itsGridPos := aGridPos;
  141.     end;
  142.  
  143.  
  144. {****************************************************}
  145. {}
  146. {        SetTargetPICT                                                                                                                                                                                                }
  147. {}
  148. {        Draw the target picture into the offscreen PixMap.                                                                                        }
  149. {}
  150. {****************************************************}
  151.  
  152.     procedure CShTile.SetTargetPICT (aPICTid: Integer);
  153.  
  154.         var
  155.             targetPicture: PicHandle;
  156.             savedAlloc: Boolean;
  157.  
  158.             tempRect: Rect;
  159.  
  160.     begin { SetTargetPICT }
  161.         itsPixMapPane.BlitPICTRes(((itsGridPos - 1) mod kMaxGridAcross) * kTileSize, ((itsGridPos - 1) div kMaxGridAcross) * kTileSize, aPICTid, FALSE);
  162.     end; { SetTargetPICT }
  163.  
  164.  
  165. {****************************************************}
  166. {}
  167. {        DrawAll                                                                                                                                                                                                                    }
  168. {}
  169. {     Draws either the hiding state or the target picture, as appropriate.                                     }
  170. {     Is essentially a pirate of the normal DrawAll method.                                                                             }
  171. {}
  172. {****************************************************}
  173.  
  174.     procedure CShTile.DrawAll (var area: Rect);
  175.  
  176.         var
  177.             tmpArea: Rect;
  178.  
  179.             ignore: Boolean;
  180.  
  181.             theRect: Rect;
  182.             thePane: CPane;    { PixMap or icon. }
  183.  
  184.             paneArea: Rect;    { Area in Pane's Frame coords. }
  185.             paneAperture: Rect;
  186.  
  187.     begin { DrawAll }
  188.         tmpArea := area;
  189.         Prepare;
  190.  
  191.         { area is in Window coordinates. Put it into Frame or QD coordinates. }
  192.         if usingLongCoord then
  193.             OffsetRect(tmpArea, thePort^.portRect.left, thePort^.portRect.top)
  194.         else
  195.             OffsetRect(tmpArea, hOrigin, vOrigin);
  196.  
  197.         ClipRect(tmpArea);
  198.  
  199.         { Need to draw a box to finish off tile for the icon. We don't need to }
  200.         { erase the frame before drawing the picture, because the Draw }
  201.         { procedure for the PixMap just CopyBits into place. The blitting }
  202.         { procedure erases the offscreen PixMap before drawing the new picture. }
  203.         if itsState = Hiding then begin
  204.             LongToQDRect(frame, theRect);
  205.             EraseRect(theRect);
  206.  
  207.             PenNormal;
  208.             FrameRect(theRect);
  209.         end; { if }
  210.  
  211.         { Clip area to aperture of this view before drawing subviews. }
  212.         FrameToWindR(aperture, tmpArea);
  213.         ignore := SectRect(tmpArea, area, tmpArea);
  214.  
  215.         if itsState = Hiding then begin
  216.             thePane := itsIcon;
  217.         end { if }
  218.         else begin
  219.             thePane := itsPixMapPane;
  220.         end; { else }
  221.  
  222.         if thePane.ReallyVisible then begin
  223.  
  224.             { DrawAll always receives the area in Window coordinates. }
  225.             { Since we are not printing, clip the area to the aperture. }
  226.             thePane.FrameToWindR(thePane.aperture, paneAperture);
  227.  
  228.             { See if area intersects the aperture of the Pane to be drawn. }
  229.             if SectRect(paneAperture, tmpArea, paneArea) then begin
  230.                 { Some portion of thePane must be drawn. }
  231.                 thePane.DrawAll(paneArea);
  232.             end; { if }
  233.         end; { if }
  234.     end; { DrawAll }
  235.  
  236.  
  237. {****************************************************}
  238. {}
  239. {        DoClick                                                                                                                                                                                                                        }
  240. {}
  241. {     Sends a message to the game director to say that it has been clicked.                             }
  242. {}
  243. {****************************************************}
  244.  
  245.     procedure CShTile.DoClick (hitPt: Point;
  246.                                     modifierKeys: integer;
  247.                                     when: longint);
  248.  
  249.     begin { DoClick }
  250.         itsGameDirector.DoTileClicked(itsGridPos);
  251.     end; { DoClick }
  252.  
  253.  
  254. {****************************************************}
  255. {}
  256. {        DoFlip                                                                                                                                                                                                                            }
  257. {}
  258. {     Flips the tile, with animation and sound as appropriate. Sound on/off is                        }
  259. {     controlled by SAT.                                                                                                                                                                                    }
  260. {}
  261. {****************************************************}
  262.  
  263.     procedure CShTile.DoFlip (aAnimate: Boolean);
  264.  
  265.         const
  266.             kTickDelay = 1;
  267.             kDivisions = 16;
  268.  
  269.         const
  270.             kSATSoundPriority = 7;
  271.  
  272.         procedure LeftToRight;
  273.  
  274.             var
  275.                 theLRect: LongRect;
  276.                 theWidth, theHeight, theCounter: Integer;
  277.  
  278.                 theOldTicks: LongInt;
  279.  
  280.                 theQDRect: Rect;
  281.  
  282.         begin { LeftToRight }
  283.             GetFrame(theLRect);
  284.             theLRect.Right := theLRect.Left;
  285.  
  286.             GetLengths(theWidth, theHeight);
  287.             theWidth := theWidth div kDivisions;
  288.  
  289.             for theCounter := 1 to kDivisions do begin
  290.                 with theLRect do begin
  291.                     Left := Right;
  292.                     Right := Left + theWidth;
  293.                 end; { with }
  294.  
  295.                 theOldTicks := TickCount;
  296.  
  297.                 FrameToWindR(theLRect, theQDRect);
  298.                 DrawAll(theQDRect);
  299.  
  300.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  301.                 end; { while }
  302.  
  303.             end; { for }
  304.         end; { LeftToRight }
  305.  
  306.         procedure RightToLeft;
  307.  
  308.             var
  309.                 theLRect: LongRect;
  310.                 theWidth, theHeight, theCounter: Integer;
  311.  
  312.                 theOldTicks: LongInt;
  313.  
  314.                 theQDRect: Rect;
  315.  
  316.         begin { RightToLeft }
  317.             GetFrame(theLRect);
  318.             theLRect.Left := theLRect.Right;
  319.  
  320.             GetLengths(theWidth, theHeight);
  321.             theWidth := theWidth div kDivisions;
  322.  
  323.             for theCounter := 1 to kDivisions do begin
  324.                 with theLRect do begin
  325.                     Right := Left;
  326.                     Left := Right - theWidth;
  327.                 end; { with }
  328.  
  329.                 theOldTicks := TickCount;
  330.  
  331.                 FrameToWindR(theLRect, theQDRect);
  332.                 DrawAll(theQDRect);
  333.  
  334.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  335.                 end; { while }
  336.  
  337.             end; { for }
  338.         end; { RightToLeft }
  339.  
  340.         procedure TopToBottom;
  341.  
  342.             var
  343.                 theLRect: LongRect;
  344.                 theWidth, theHeight, theCounter: Integer;
  345.  
  346.                 theOldTicks: LongInt;
  347.  
  348.                 theQDRect: Rect;
  349.  
  350.         begin { TopToBottom }
  351.             GetFrame(theLRect);
  352.             theLRect.Bottom := theLRect.Top;
  353.  
  354.             GetLengths(theWidth, theHeight);
  355.             theHeight := theHeight div kDivisions;
  356.  
  357.             for theCounter := 1 to kDivisions do begin
  358.                 with theLRect do begin
  359.                     Top := Bottom;
  360.                     Bottom := Top + theHeight;
  361.                 end; { with }
  362.  
  363.                 theOldTicks := TickCount;
  364.  
  365.                 FrameToWindR(theLRect, theQDRect);
  366.                 DrawAll(theQDRect);
  367.  
  368.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  369.                 end; { while }
  370.  
  371.             end; { for }
  372.         end; { TopToBottom }
  373.  
  374.         procedure BottomToTop;
  375.  
  376.             var
  377.                 theLRect: LongRect;
  378.                 theWidth, theHeight, theCounter: Integer;
  379.  
  380.                 theOldTicks: LongInt;
  381.  
  382.                 theQDRect: Rect;
  383.  
  384.         begin { BottomToTop }
  385.             GetFrame(theLRect);
  386.             theLRect.Top := theLRect.Bottom;
  387.  
  388.             GetLengths(theWidth, theHeight);
  389.             theHeight := theHeight div kDivisions;
  390.  
  391.             theOldTicks := TickCount;
  392.             for theCounter := 1 to kDivisions do begin
  393.                 with theLRect do begin
  394.                     Bottom := Top;
  395.                     Top := Bottom - theHeight;
  396.                 end; { with }
  397.  
  398.                 theOldTicks := TickCount;
  399.  
  400.                 FrameToWindR(theLRect, theQDRect);
  401.                 DrawAll(theQDRect);
  402.  
  403.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  404.                 end; { while }
  405.  
  406.             end; { for }
  407.         end; { BottomToTop }
  408.  
  409.         procedure LeftUpRightDown;
  410.  
  411.             var
  412.                 theLRectLeft, theLRectRight: LongRect;
  413.                 theWidth, theHeight, theCounter: Integer;
  414.  
  415.                 theOldTicks: LongInt;
  416.  
  417.                 theQDRect: Rect;
  418.  
  419.         begin { LeftUpRightDown }
  420.             GetFrame(theLRectLeft);
  421.             theLRectRight := theLRectLeft;
  422.  
  423.             with theLRectLeft do begin
  424.                 Top := Bottom;
  425.                 Right := (Left + Right) div 2;
  426.             end; { with }
  427.  
  428.             with theLRectRight do begin
  429.                 Bottom := Top;
  430.                 Left := theLRectLeft.Right;
  431.             end; { with }
  432.  
  433.             GetLengths(theWidth, theHeight);
  434.             theHeight := theHeight div kDivisions;
  435.  
  436.             for theCounter := 1 to kDivisions do begin
  437.                 with theLRectLeft do begin
  438.                     Bottom := Top;
  439.                     Top := Bottom - theHeight;
  440.                 end; { with }
  441.  
  442.                 with theLRectRight do begin
  443.                     Top := Bottom;
  444.                     Bottom := Top + theHeight;
  445.                 end; { with }
  446.  
  447.                 theOldTicks := TickCount;
  448.  
  449.                 FrameToWindR(theLRectLeft, theQDRect);
  450.                 DrawAll(theQDRect);
  451.                 FrameToWindR(theLRectRight, theQDRect);
  452.                 DrawAll(theQDRect);
  453.  
  454.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  455.                 end; { while }
  456.  
  457.             end; { for }
  458.         end; { LeftUpRightDown }
  459.  
  460.         procedure LeftDownRightUp;
  461.  
  462.             var
  463.                 theLRectLeft, theLRectRight: LongRect;
  464.                 theWidth, theHeight, theCounter: Integer;
  465.  
  466.                 theOldTicks: LongInt;
  467.  
  468.                 theQDRect: Rect;
  469.  
  470.         begin { LeftDownRightUp }
  471.             GetFrame(theLRectLeft);
  472.             theLRectRight := theLRectLeft;
  473.  
  474.             with theLRectLeft do begin
  475.                 Bottom := Top;
  476.                 Right := (Left + Right) div 2; { Pane coordinates. }
  477.             end; { with }
  478.  
  479.             with theLRectRight do begin
  480.                 Top := Bottom;
  481.                 Left := theLRectLeft.Right;
  482.             end; { with }
  483.  
  484.             GetLengths(theWidth, theHeight);
  485.             theHeight := theHeight div kDivisions;
  486.  
  487.             for theCounter := 1 to kDivisions do begin
  488.                 with theLRectLeft do begin
  489.                     Top := Bottom;
  490.                     Bottom := Top + theHeight;
  491.                 end; { with }
  492.  
  493.                 with theLRectRight do begin
  494.                     Bottom := Top;
  495.                     Top := Bottom - theHeight;
  496.                 end; { with }
  497.  
  498.                 theOldTicks := TickCount;
  499.  
  500.                 FrameToWindR(theLRectLeft, theQDRect);
  501.                 DrawAll(theQDRect);
  502.                 FrameToWindR(theLRectRight, theQDRect);
  503.                 DrawAll(theQDRect);
  504.  
  505.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  506.                 end; { while }
  507.  
  508.             end; { for }
  509.         end; { LeftDownRightUp }
  510.  
  511.         procedure TopLRBottomRL;
  512.  
  513.             var
  514.                 theLRectTop, theLRectBottom: LongRect;
  515.                 theWidth, theHeight, theCounter: Integer;
  516.  
  517.                 theOldTicks: LongInt;
  518.  
  519.                 theQDRect: Rect;
  520.  
  521.         begin { TopLRBottomRL }
  522.             GetFrame(theLRectTop);
  523.             theLRectBottom := theLRectTop;
  524.  
  525.             with theLRectTop do begin
  526.                 Right := Left;
  527.                 Bottom := (Top + Bottom) div 2; { Pane coordinates. }
  528.             end; { with }
  529.  
  530.             with theLRectBottom do begin
  531.                 Left := Right;
  532.                 Top := theLRectTop.Bottom;
  533.             end; { with }
  534.  
  535.             GetLengths(theWidth, theHeight);
  536.             theWidth := theWidth div kDivisions;
  537.  
  538.             for theCounter := 1 to kDivisions do begin
  539.  
  540.                 with theLRectTop do begin
  541.                     Left := Right;
  542.                     Right := Left + theWidth;
  543.                 end; { with }
  544.  
  545.                 with theLRectBottom do begin
  546.                     Right := Left;
  547.                     Left := Right - theWidth;
  548.                 end; { with }
  549.  
  550.                 theOldTicks := TickCount;
  551.  
  552.                 FrameToWindR(theLRectTop, theQDRect);
  553.                 DrawAll(theQDRect);
  554.                 FrameToWindR(theLRectBottom, theQDRect);
  555.                 DrawAll(theQDRect);
  556.  
  557.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  558.                 end; { while }
  559.  
  560.             end; { for }
  561.         end; { TopLRBottomRL }
  562.  
  563.         procedure TopRLBottomLR;
  564.  
  565.             var
  566.                 theLRectTop, theLRectBottom: LongRect;
  567.                 theWidth, theHeight, theCounter: Integer;
  568.  
  569.                 theOldTicks: LongInt;
  570.  
  571.                 theQDRect: Rect;
  572.  
  573.         begin { TopRLBottomLR }
  574.             GetFrame(theLRectTop);
  575.             theLRectBottom := theLRectTop;
  576.  
  577.             with theLRectTop do begin
  578.                 Left := Right;
  579.                 Bottom := (Top + Bottom) div 2; { Pane coordinates. }
  580.             end; { with }
  581.  
  582.             with theLRectBottom do begin
  583.                 Right := Left;
  584.                 Top := theLRectTop.Bottom;
  585.             end; { with }
  586.  
  587.             GetLengths(theWidth, theHeight);
  588.             theWidth := theWidth div kDivisions;
  589.  
  590.             for theCounter := 1 to kDivisions do begin
  591.                 with theLRectTop do begin
  592.                     Right := Left;
  593.                     Left := Right - theWidth;
  594.                 end; { with }
  595.  
  596.                 with theLRectBottom do begin
  597.                     Left := Right;
  598.                     Right := Left + theWidth;
  599.                 end; { with }
  600.  
  601.                 theOldTicks := TickCount;
  602.  
  603.                 FrameToWindR(theLRectTop, theQDRect);
  604.                 DrawAll(theQDRect);
  605.                 FrameToWindR(theLRectBottom, theQDRect);
  606.                 DrawAll(theQDRect);
  607.  
  608.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  609.                 end; { while }
  610.  
  611.             end; { for }
  612.         end; { TopRLBottomLR }
  613.  
  614.         procedure DiagTLtoBR;
  615.  
  616.             var
  617.                 theLRectVer, theLRectHor: LongRect;
  618.                 theWidth, theHeight, theCounter: Integer;
  619.  
  620.                 theOldTicks: LongInt;
  621.  
  622.                 theQDRect: Rect;
  623.  
  624.         begin { DiagTLtoBR }
  625.             GetFrame(theLRectVer);
  626.             theLRectHor := theLRectVer;
  627.  
  628.             theLRectVer.botRight := theLRectVer.topLeft;
  629.             theLRectHor.botRight := theLRectHor.topLeft;
  630.  
  631.             GetLengths(theWidth, theHeight);
  632.             theWidth := theWidth div kDivisions;
  633.             theHeight := theHeight div kDivisions;
  634.  
  635.             for theCounter := 1 to kDivisions do begin
  636.                 with theLRectVer do begin
  637.                     Left := Right;
  638.                     Right := Left + theWidth;
  639.                     Bottom := Bottom + theHeight;
  640.                 end; { with }
  641.  
  642.                 with theLRectHor do begin
  643.                     Top := Bottom;
  644.                     Bottom := Top + theHeight;
  645.                     Right := Right + theWidth;
  646.                 end; { with }
  647.  
  648.                 theOldTicks := TickCount;
  649.  
  650.                 FrameToWindR(theLRectVer, theQDRect);
  651.                 DrawAll(theQDRect);
  652.                 FrameToWindR(theLRectHor, theQDRect);
  653.                 DrawAll(theQDRect);
  654.  
  655.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  656.                 end; { while }
  657.  
  658.             end; { for }
  659.         end; { DiagTLtoBR }
  660.  
  661.         procedure DiagBRtoTL;
  662.  
  663.             var
  664.                 theLRectVer, theLRectHor: LongRect;
  665.                 theWidth, theHeight, theCounter: Integer;
  666.  
  667.                 theOldTicks: LongInt;
  668.  
  669.                 theQDRect: Rect;
  670.  
  671.         begin { DiagBRtoTL }
  672.             GetFrame(theLRectVer);
  673.             theLRectHor := theLRectVer;
  674.  
  675.             theLRectVer.topLeft := theLRectVer.botRight;
  676.             theLRectHor.topLeft := theLRectHor.botRight;
  677.  
  678.             GetLengths(theWidth, theHeight);
  679.             theWidth := theWidth div kDivisions;
  680.             theHeight := theHeight div kDivisions;
  681.  
  682.             for theCounter := 1 to kDivisions do begin
  683.                 with theLRectVer do begin
  684.                     Right := Left;
  685.                     Left := Right - theWidth;
  686.                     Top := Top - theHeight;
  687.                 end; { with }
  688.  
  689.                 with theLRectHor do begin
  690.                     Bottom := Top;
  691.                     Top := Bottom - theHeight;
  692.                     Left := Left - theWidth;
  693.                 end; { with }
  694.  
  695.                 theOldTicks := TickCount;
  696.  
  697.                 FrameToWindR(theLRectVer, theQDRect);
  698.                 DrawAll(theQDRect);
  699.                 FrameToWindR(theLRectHor, theQDRect);
  700.                 DrawAll(theQDRect);
  701.  
  702.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  703.                 end; { while }
  704.  
  705.             end; { for }
  706.         end; { DiagBRtoTL }
  707.  
  708.         procedure DiagTRtoBL;
  709.  
  710.             var
  711.                 theLRectVer, theLRectHor: LongRect;
  712.                 theWidth, theHeight, theCounter: Integer;
  713.  
  714.                 theOldTicks: LongInt;
  715.  
  716.                 theQDRect: Rect;
  717.  
  718.         begin { DiagTRtoBL }
  719.             GetFrame(theLRectVer);
  720.             theLRectHor := theLRectVer;
  721.  
  722.             with theLRectVer do begin
  723.                 Bottom := Top;
  724.                 Left := Right;
  725.             end; { with }
  726.  
  727.             with theLRectHor do begin
  728.                 Bottom := Top;
  729.                 Left := Right;
  730.             end; { with }
  731.  
  732.             GetLengths(theWidth, theHeight);
  733.             theWidth := theWidth div kDivisions;
  734.             theHeight := theHeight div kDivisions;
  735.  
  736.             for theCounter := 1 to kDivisions do begin
  737.                 with theLRectVer do begin
  738.                     Right := Left;
  739.                     Left := Right - theWidth;
  740.                     Bottom := Bottom + theHeight;
  741.                 end; { with }
  742.  
  743.                 with theLRectHor do begin
  744.                     Top := Bottom;
  745.                     Bottom := Top + theHeight;
  746.                     Left := Left - theWidth;
  747.                 end; { with }
  748.  
  749.                 theOldTicks := TickCount;
  750.  
  751.                 FrameToWindR(theLRectVer, theQDRect);
  752.                 DrawAll(theQDRect);
  753.                 FrameToWindR(theLRectHor, theQDRect);
  754.                 DrawAll(theQDRect);
  755.  
  756.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  757.                 end; { while }
  758.  
  759.             end; { for }
  760.         end; { DiagTRtoBL }
  761.  
  762.         procedure DiagBLtoTR;
  763.  
  764.             var
  765.                 theLRectVer, theLRectHor: LongRect;
  766.                 theWidth, theHeight, theCounter: Integer;
  767.  
  768.                 theOldTicks: LongInt;
  769.  
  770.                 theQDRect: Rect;
  771.  
  772.         begin { DiagBLtoTR }
  773.             GetFrame(theLRectVer);
  774.             theLRectHor := theLRectVer;
  775.  
  776.             with theLRectVer do begin
  777.                 Top := Bottom;
  778.                 Right := Left;
  779.             end; { with }
  780.  
  781.             with theLRectHor do begin
  782.                 Top := Bottom;
  783.                 Right := Left;
  784.             end; { with }
  785.  
  786.             GetLengths(theWidth, theHeight);
  787.             theWidth := theWidth div kDivisions;
  788.             theHeight := theHeight div kDivisions;
  789.  
  790.             for theCounter := 1 to kDivisions do begin
  791.                 with theLRectVer do begin
  792.                     Left := Right;
  793.                     Right := Left + theWidth;
  794.                     Top := Top - theHeight;
  795.                 end; { with }
  796.  
  797.                 with theLRectHor do begin
  798.                     Bottom := Top;
  799.                     Top := Bottom - theHeight;
  800.                     Right := Right + theWidth;
  801.                 end; { with }
  802.  
  803.                 theOldTicks := TickCount;
  804.  
  805.                 FrameToWindR(theLRectVer, theQDRect);
  806.                 DrawAll(theQDRect);
  807.                 FrameToWindR(theLRectHor, theQDRect);
  808.                 DrawAll(theQDRect);
  809.  
  810.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  811.                 end; { while }
  812.  
  813.             end; { for }
  814.         end; { DiagBLtoTR }
  815.  
  816.         procedure InwardsHor;
  817.  
  818.             var
  819.                 theLRectLeft, theLRectRight: LongRect;
  820.                 theWidth, theHeight, theCounter: Integer;
  821.  
  822.                 theOldTicks: LongInt;
  823.  
  824.                 theQDRect: Rect;
  825.  
  826.         begin { InwardsHor }
  827.             GetFrame(theLRectLeft);
  828.             theLRectRight := theLRectLeft;
  829.  
  830.             theLRectLeft.Right := theLRectLeft.Left;
  831.             theLRectRight.Left := theLRectRight.Right;
  832.  
  833.             GetLengths(theWidth, theHeight);
  834.             theWidth := theWidth div kDivisions;
  835.  
  836.             for theCounter := 1 to kDivisions div 2 do begin
  837.                 with theLRectLeft do begin
  838.                     Left := Right;
  839.                     Right := Left + theWidth;
  840.                 end; { with }
  841.                 with theLRectRight do begin
  842.                     Right := Left;
  843.                     Left := Right - theWidth;
  844.                 end; { with }
  845.  
  846.                 theOldTicks := TickCount;
  847.  
  848.                 FrameToWindR(theLRectLeft, theQDRect);
  849.                 DrawAll(theQDRect);
  850.                 FrameToWindR(theLRectRight, theQDRect);
  851.                 DrawAll(theQDRect);
  852.  
  853.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  854.                 end; { while }
  855.  
  856.             end; { for }
  857.         end; { InwardsHor }
  858.  
  859.         procedure OutwardsHor;
  860.  
  861.             var
  862.                 theLRectLeft, theLRectRight: LongRect;
  863.                 theWidth, theHeight, theCounter: Integer;
  864.  
  865.                 theOldTicks: LongInt;
  866.  
  867.                 theQDRect: Rect;
  868.  
  869.         begin { OutwardsHor }
  870.             GetFrame(theLRectLeft);
  871.             theLRectRight := theLRectLeft;
  872.  
  873.             with theLRectLeft do begin
  874.                 Right := (Left + Right) div 2;
  875.                 Left := Right;
  876.             end; { with }
  877.  
  878.             with theLRectRight do begin
  879.                 Left := (Left + Right) div 2;
  880.                 Right := Left;
  881.             end; { with }
  882.  
  883.             GetLengths(theWidth, theHeight);
  884.             theWidth := theWidth div kDivisions;
  885.  
  886.             for theCounter := 1 to kDivisions div 2 do begin
  887.                 with theLRectLeft do begin
  888.                     Right := Left;
  889.                     Left := Right - theWidth;
  890.                 end; { with }
  891.                 with theLRectRight do begin
  892.                     Left := Right;
  893.                     Right := Left + theWidth;
  894.                 end; { with }
  895.  
  896.                 theOldTicks := TickCount;
  897.  
  898.                 FrameToWindR(theLRectLeft, theQDRect);
  899.                 DrawAll(theQDRect);
  900.                 FrameToWindR(theLRectRight, theQDRect);
  901.                 DrawAll(theQDRect);
  902.  
  903.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  904.                 end; { while }
  905.  
  906.             end; { for }
  907.         end; { OutwardsHor }
  908.  
  909.         procedure InwardsVer;
  910.  
  911.             var
  912.                 theLRectTop, theLRectBottom: LongRect;
  913.                 theWidth, theHeight, theCounter: Integer;
  914.  
  915.                 theOldTicks: LongInt;
  916.  
  917.                 theQDRect: Rect;
  918.  
  919.         begin { InwardsVer }
  920.             GetFrame(theLRectTop);
  921.             theLRectBottom := theLRectTop;
  922.  
  923.             theLRectTop.Bottom := theLRectTop.Top;
  924.             theLRectBottom.Top := theLRectBottom.Bottom;
  925.  
  926.             GetLengths(theWidth, theHeight);
  927.             theHeight := theHeight div kDivisions;
  928.  
  929.             for theCounter := 1 to kDivisions div 2 do begin
  930.                 with theLRectTop do begin
  931.                     Top := Bottom;
  932.                     Bottom := Top + theHeight;
  933.                 end; { with }
  934.                 with theLRectBottom do begin
  935.                     Bottom := Top;
  936.                     Top := Bottom - theHeight;
  937.                 end; { with }
  938.  
  939.                 theOldTicks := TickCount;
  940.  
  941.                 FrameToWindR(theLRectTop, theQDRect);
  942.                 DrawAll(theQDRect);
  943.                 FrameToWindR(theLRectBottom, theQDRect);
  944.                 DrawAll(theQDRect);
  945.  
  946.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  947.                 end; { while }
  948.  
  949.             end; { for }
  950.         end; { InwardsVer }
  951.  
  952.         procedure OutwardsVer;
  953.  
  954.             var
  955.                 theLRectTop, theLRectBottom: LongRect;
  956.                 theWidth, theHeight, theCounter: Integer;
  957.  
  958.                 theOldTicks: LongInt;
  959.  
  960.                 theQDRect: Rect;
  961.  
  962.         begin { OutwardsVer }
  963.             GetFrame(theLRectTop);
  964.             theLRectBottom := theLRectTop;
  965.  
  966.             with theLRectTop do begin
  967.                 Bottom := (Top + Bottom) div 2;
  968.                 Top := Bottom;
  969.             end; { with }
  970.  
  971.             with theLRectBottom do begin
  972.                 Top := (Top + Bottom) div 2;
  973.                 Bottom := Top;
  974.             end; { with }
  975.  
  976.             GetLengths(theWidth, theHeight);
  977.             theHeight := theHeight div kDivisions;
  978.  
  979.             for theCounter := 1 to kDivisions div 2 do begin
  980.                 with theLRectTop do begin
  981.                     Bottom := Top;
  982.                     Top := Bottom - theHeight;
  983.                 end; { with }
  984.                 with theLRectBottom do begin
  985.                     Top := Bottom;
  986.                     Bottom := Top + theHeight;
  987.                 end; { with }
  988.  
  989.                 theOldTicks := TickCount;
  990.  
  991.                 FrameToWindR(theLRectTop, theQDRect);
  992.                 DrawAll(theQDRect);
  993.                 FrameToWindR(theLRectBottom, theQDRect);
  994.                 DrawAll(theQDRect);
  995.  
  996.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  997.                 end; { while }
  998.  
  999.             end; { for }
  1000.         end; { OutwardsVer }
  1001.  
  1002.         procedure CentreIn;
  1003.  
  1004.             var
  1005.                 theLRectLeft, theLRectTop, theLRectRight, theLRectBottom: LongRect;
  1006.                 theWidth, theHeight, theCounter: Integer;
  1007.  
  1008.                 theOldTicks: LongInt;
  1009.  
  1010.                 theQDRect: Rect;
  1011.  
  1012.         begin { CentreIn }
  1013.             GetFrame(theLRectLeft);
  1014.             theLRectTop := theLRectLeft;
  1015.             theLRectRight := theLRectLeft;
  1016.             theLRectBottom := theLRectLeft;
  1017.  
  1018.             GetLengths(theWidth, theHeight);
  1019.             theWidth := theWidth div kDivisions;
  1020.             theHeight := theHeight div kDivisions;
  1021.  
  1022.             with theLRectLeft do begin
  1023.                 Right := Left;
  1024.                 Top := Top - theHeight;
  1025.                 Bottom := Bottom + theHeight;
  1026.             end; { with }
  1027.  
  1028.             with theLRectTop do begin
  1029.                 Bottom := Top;
  1030.                 Left := Left - theWidth;
  1031.                 Right := Right + theWidth;
  1032.             end; { with }
  1033.  
  1034.             with theLRectRight do begin
  1035.                 Left := Right;
  1036.                 Top := Top - theHeight;
  1037.                 Bottom := Bottom + theHeight;
  1038.             end; { with }
  1039.  
  1040.             with theLRectBottom do begin
  1041.                 Top := Bottom;
  1042.                 Left := Left - theWidth;
  1043.                 Right := Right + theWidth;
  1044.             end; { with }
  1045.  
  1046.             for theCounter := 1 to kDivisions div 2 do begin
  1047.                 with theLRectLeft do begin
  1048.                     Left := Right;
  1049.                     Right := Left + theWidth;
  1050.                     Top := Top + theHeight;
  1051.                     Bottom := Bottom - theHeight;
  1052.                 end; { with }
  1053.                 with theLRectTop do begin
  1054.                     Top := Bottom;
  1055.                     Bottom := Top + theHeight;
  1056.                     Left := Left + theWidth;
  1057.                     Right := Right - theWidth;
  1058.                 end; { with }
  1059.                 with theLRectRight do begin
  1060.                     Right := Left;
  1061.                     Left := Right - theWidth;
  1062.                     Top := Top + theHeight;
  1063.                     Bottom := Bottom - theHeight;
  1064.                 end; { with }
  1065.                 with theLRectBottom do begin
  1066.                     Bottom := Top;
  1067.                     Top := Bottom - theHeight;
  1068.                     Left := Left + theWidth;
  1069.                     Right := Right - theWidth;
  1070.                 end; { with }
  1071.  
  1072.                 theOldTicks := TickCount;
  1073.  
  1074.                 FrameToWindR(theLRectLeft, theQDRect);
  1075.                 DrawAll(theQDRect);
  1076.                 FrameToWindR(theLRectTop, theQDRect);
  1077.                 DrawAll(theQDRect);
  1078.                 FrameToWindR(theLRectRight, theQDRect);
  1079.                 DrawAll(theQDRect);
  1080.                 FrameToWindR(theLRectBottom, theQDRect);
  1081.                 DrawAll(theQDRect);
  1082.  
  1083.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  1084.                 end; { while }
  1085.  
  1086.             end; { for }
  1087.         end; { CentreIn }
  1088.  
  1089.         procedure CentreOut;
  1090.  
  1091.             var
  1092.                 theLRectLeft, theLRectTop, theLRectRight, theLRectBottom: LongRect;
  1093.                 theWidth, theHeight, theCounter: Integer;
  1094.  
  1095.                 theOldTicks: LongInt;
  1096.  
  1097.                 theQDRect: Rect;
  1098.  
  1099.         begin { CentreOut }
  1100.             GetFrame(theLRectLeft);
  1101.             theLRectTop := theLRectLeft;
  1102.             theLRectRight := theLRectLeft;
  1103.             theLRectBottom := theLRectLeft;
  1104.  
  1105.             with theLRectLeft do begin
  1106.                 Right := (Left + Right) div 2;
  1107.                 Bottom := (Top + Bottom) div 2;
  1108.                 Left := Right;
  1109.                 Top := Bottom;
  1110.             end; { with }
  1111.  
  1112.             with theLRectTop do begin
  1113.                 Bottom := (Top + Bottom) div 2;
  1114.                 Right := (Left + Right) div 2;
  1115.                 Top := Bottom;
  1116.                 Left := Right;
  1117.             end; { with }
  1118.  
  1119.             with theLRectRight do begin
  1120.                 Left := (Left + Right) div 2;
  1121.                 Bottom := (Top + Bottom) div 2;
  1122.                 Right := Left;
  1123.                 Top := Bottom;
  1124.             end; { with }
  1125.  
  1126.             with theLRectBottom do begin
  1127.                 Top := (Top + Bottom) div 2;
  1128.                 Right := (Left + Right) div 2;
  1129.                 Bottom := Top;
  1130.                 Left := Right;
  1131.             end; { with }
  1132.  
  1133.             GetLengths(theWidth, theHeight);
  1134.             theWidth := theWidth div kDivisions;
  1135.             theHeight := theHeight div kDivisions;
  1136.  
  1137.             for theCounter := 1 to kDivisions div 2 do begin
  1138.                 with theLRectLeft do begin
  1139.                     Right := Left;
  1140.                     Left := Right - theWidth;
  1141.                     Top := Top - theHeight;
  1142.                     Bottom := Bottom + theHeight;
  1143.                 end; { with }
  1144.                 with theLRectTop do begin
  1145.                     Bottom := Top;
  1146.                     Top := Bottom - theHeight;
  1147.                     Left := Left - theWidth;
  1148.                     Right := Right + theWidth;
  1149.                 end; { with }
  1150.                 with theLRectRight do begin
  1151.                     Left := Right;
  1152.                     Right := Left + theWidth;
  1153.                     Top := Top - theHeight;
  1154.                     Bottom := Bottom + theHeight;
  1155.                 end; { with }
  1156.                 with theLRectBottom do begin
  1157.                     Top := Bottom;
  1158.                     Bottom := Top + theHeight;
  1159.                     Left := Left - theWidth;
  1160.                     Right := Right + theWidth;
  1161.                 end; { with }
  1162.  
  1163.                 theOldTicks := TickCount;
  1164.  
  1165.                 FrameToWindR(theLRectLeft, theQDRect);
  1166.                 DrawAll(theQDRect);
  1167.                 FrameToWindR(theLRectTop, theQDRect);
  1168.                 DrawAll(theQDRect);
  1169.                 FrameToWindR(theLRectRight, theQDRect);
  1170.                 DrawAll(theQDRect);
  1171.                 FrameToWindR(theLRectBottom, theQDRect);
  1172.                 DrawAll(theQDRect);
  1173.  
  1174.                 while TickCount < theOldTicks + kTickDelay do begin { Nothing }
  1175.                 end; { while }
  1176.  
  1177.             end; { for }
  1178.         end; { CentreOut }
  1179.  
  1180.         procedure FlipWithoutAnimation;
  1181.  
  1182.             var
  1183.                 theLRect: LongRect;
  1184.                 theQDRect: Rect;
  1185.  
  1186.         begin { FlipWithoutAnimation }
  1187.             GetFrame(theLRect);
  1188.             FrameToWindR(theLRect, theQDRect);
  1189.             DrawAll(theQDRect);
  1190.         end; { FlipWithoutAnimation }
  1191.  
  1192.     begin { DoFlip }
  1193.         if itsState = Hiding then begin
  1194.             itsState := Showing;
  1195.         end { if }
  1196.         else begin
  1197.             itsState := Hiding;
  1198.         end; { else }
  1199.  
  1200.         { Do sound first (asynchronously). }
  1201.         { SAT handles sound being on or off . }
  1202.  
  1203.         if gNumFlipSounds > 0 then begin
  1204. {$PUSH}
  1205. {$R-}
  1206.             SATSoundPlay(gFlipSoundHandles^^[Abs(Random) mod gNumFlipSounds + 1], kSATSoundPriority, TRUE);
  1207. {$POP}
  1208.         end; { if }
  1209.  
  1210.         SATSoundEvents;
  1211.  
  1212.         if aAnimate then begin
  1213.             case Abs(Random) mod 18 of
  1214.                 0:  begin
  1215.                     LeftToRight;
  1216.                 end; { 0 }
  1217.                 1:  begin
  1218.                     RightToLeft;
  1219.                 end; { 1 }
  1220.                 2:  begin
  1221.                     TopToBottom;
  1222.                 end; { 2 }
  1223.                 3:  begin
  1224.                     BottomToTop;
  1225.                 end; { 3 }
  1226.                 4:  begin
  1227.                     LeftUpRightDown;
  1228.                 end; { 4 }
  1229.                 5:  begin
  1230.                     LeftDownRightUp;
  1231.                 end; { 5 }
  1232.                 6:  begin
  1233.                     TopLRBottomRL;
  1234.                 end; { 6 }
  1235.                 7:  begin
  1236.                     TopRLBottomLR;
  1237.                 end; { 7 }
  1238.                 8:  begin
  1239.                     DiagTLtoBR;
  1240.                 end; { 8 }
  1241.                 9:  begin
  1242.                     DiagTRtoBL;
  1243.                 end; { 9 }
  1244.                 10:  begin
  1245.                     DiagBRtoTL;
  1246.                 end; { 10 }
  1247.                 11:  begin
  1248.                     DiagBLtoTR;
  1249.                 end; { 11 }
  1250.                 12:  begin
  1251.                     InwardsHor;
  1252.                 end; { 12 }
  1253.                 13:  begin
  1254.                     OutwardsHor;
  1255.                 end; { 13 }
  1256.                 14:  begin
  1257.                     InwardsVer;
  1258.                 end; { 12 }
  1259.                 15:  begin
  1260.                     OutwardsVer;
  1261.                 end; { 13 }
  1262.                 16:  begin
  1263.                     CentreIn;
  1264.                 end; { 12 }
  1265.                 17:  begin
  1266.                     CentreOut;
  1267.                 end; { 13 }
  1268.             end; { case }
  1269.         end { if }
  1270.         else begin
  1271.             FlipWithoutAnimation;
  1272.         end; { else }
  1273.     end; { DoFlip }
  1274.  
  1275.  
  1276. end. { CShTile }